package tr.edu.yildiz.ce.dap.acm.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class CacheProperties {

	public static final String CACHE_FOLDER = "cache.folder";
	public static final String CACHE_FILE = "cache.file";
	public static final String HOSTNAME = "cache.hostname";
	public static final String PORT = "cache.port";
	
	private static CacheProperties instance;
	private Properties properties; 
	
	public static CacheProperties getInstance(){
		if (instance == null)
			instance = new CacheProperties();
		return instance;
	}
	
	public CacheProperties(){
		String cachePropPath = System.getProperty("cache.properties");
		properties = new Properties();
		try {
			properties.load(new FileReader(new File(cachePropPath)));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	
	public String getCacheFolder(){
		return properties.getProperty(CACHE_FOLDER);
	}
	
	public File getCacheFile(){
		return new File(properties.getProperty(CACHE_FILE));
	}
	
	public String getHostname() {
		return properties.getProperty(HOSTNAME);
	}
	
	public String getPort() {
		return properties.getProperty(PORT);
	}
	
	
}
